-- WITH u AS ( SELECT id FROM users WHERE name='admin' ),
--      r AS ( SELECT  FROM room WHERE name='public' )
-- INSERT INTO msg_room (src, content, dist)
--   SELECT users.id, '{"t": "txt", "v": "78787877878"}', 1
--   FROM users WHERE name='admin';

INSERT INTO msg_room (src, content, dist) VALUES (1, '{"t": "txt", "v": "78787877878"}', 1);

-- CREATE OR REPLACE FUNCTION test1InsertRoomMsg()
--   RETURNS VOID
-- AS $$
-- DECLARE
-- BEGIN
--   WITH u AS ( SELECT id
--               FROM users
--               WHERE name = 'admin' ),
--       r AS ( SELECT
--              FROM room
--              WHERE name = 'public' )
--   INSERT INTO msg_room (src, content, dist)
--     SELECT users.id, '{"t": "txt", "v": "78787877878"}', 1
--     FROM users
--     WHERE name = 'admin';
--   RETURN;
-- END
-- $$ LANGUAGE 'plpgsql';

-- SELECT test1InsertRoomMsg();

---- pgbench -U chat -M prepared -n -r -P 1 -f ./insertRoomMsg.sql -c 48 -j 48 -T 10000